from flask import Blueprint, request
from flask_restful import Api, Resource, marshal_with

from webapp.config.api_utils import oper_log, check_auth
from webapp.dto_mapper import score_page_fields, score_options_page_fields
from webapp.service.score_service import ScoreService

score_option_app = Blueprint('scoreoption', __name__, url_prefix='/api/score/options')
score_option_api = Api(score_option_app)


@score_option_api.resource("", "/")
class ScoOptionsApi(Resource):
    @oper_log('进行录入分数时添加和编辑时需要的选项', request)
    @check_auth('score:list', request)
    @marshal_with(score_options_page_fields)
    def get(self):
        return ScoreService.query_all_options()
